<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    canvas{
      border: 4px solid red;
    }
  </style>
</head>
<body>
  <canvas width="800" height="420"></canvas>
</body>
<script>
    var canvas = document.querySelector('canvas')
    var ctx = canvas.getContext('2d')

    //绘制左上角的文字
    ctx.font = '18px 微软雅黑'
    ctx.fillStyle = 'green'
    ctx.fillText('数据可视化',70,70)
    //绘制x，y轴
    ctx.moveTo(100,100)
    ctx.lineTo(100,400)
    ctx.lineTo(700,400)
    ctx.stroke()
    //绘制图里的横线及旁边的数字150
    ctx.moveTo(100,100)
    ctx.lineTo(700,100)
    ctx.stroke()
    ctx.fillText('150',60,110)

    ctx.moveTo(100,160)
    ctx.lineTo(700,160)
    ctx.stroke()
    ctx.fillText('120',60,170)

    ctx.moveTo(100,220)
    ctx.lineTo(700,220)
    ctx.stroke()
    ctx.fillText('90',60,230)

    ctx.moveTo(100,280)
    ctx.lineTo(700,280)
    ctx.stroke()
    ctx.fillText('60',60,290)

    ctx.moveTo(100,340)
    ctx.lineTo(700,340)
    ctx.stroke()
    ctx.fillText('30',60,350)
    ctx.fillText('0',60,400)
    //绘制x轴上文字等
    ctx.fillText('食品',170,417)
    ctx.moveTo(250,400)
    ctx.lineTo(250,410)
    ctx.stroke()
    ctx.fillText('数码',320,417)

    ctx.moveTo(400,400)
    ctx.lineTo(400,410)
    ctx.stroke()
    ctx.fillText('服装',470,417)

    ctx.moveTo(550,400)
    ctx.lineTo(550,410)
    ctx.stroke()
    ctx.fillText('箱包',620,417)
    // 绘制柱状图
    ctx.fillStyle = 'red'
    ctx.fillRect(120,200,110,200)
</script>
</html>